package cn.itsource.controller.app;

import cn.dev33.satoken.annotation.SaIgnore;
import cn.itsource.pojo.ro.DriverOnLine;
import cn.itsource.pojo.ro.GeoRo;
import cn.itsource.pojo.ro.WxChatRegisterRo;
import cn.itsource.result.JSONResult;
import cn.itsource.service.IDriverService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;

@Tag(name = "司机对象",description = "司机对象")
@RestController
@RequestMapping("/app/driver")
public class AppDriverController {

    @Autowired
    private IDriverService driverService;
    
    @Operation( summary= "注册Driver",description = "基础对象注册接口")
    @Parameter(name = "",description = "注册的对象",required = true)
    @PostMapping
    @SaIgnore
    public JSONResult phoneRegister(@RequestBody @Valid WxChatRegisterRo registerRo){
        return driverService.phoneRegister(registerRo);
    }

    /**
     * 开始接单时是上传地址
     * @return
     */
    @PostMapping("/onLine")
    public JSONResult onLine(@RequestBody @Valid DriverOnLine driverOnLine){
        return JSONResult.success(driverService.onLine(driverOnLine));
    }

    @PostMapping("/OffLine")
    public JSONResult OffLine(){
        driverService.OffLine();
        return JSONResult.success();
    }

    @PostMapping("/geo")
    public JSONResult geo(@RequestBody @Valid GeoRo geoRo){
        driverService.geo(geoRo);
        return JSONResult.success();
    }

}
